<template>
  <view>
    <nut-button type="primary" @click="onJoin">授权登陆</nut-button>
    <view class="flex-center m-4 p-4 bg-red-500">
      <cell bind:startmessage='startmessage' bind:completemessage="completemessage" :url='url'  />
    </view>
    <view class="flex-center m-4 p-4 bg-red-500">
      <nut-button type="primary" @click="show = true">打开弹窗</nut-button>
    </view>

    <nut-popup v-model:visible="show" position="bottom">
      <view class="flex-col flex-center w-full">
        <tags class="w-full"/>
        <view class="flex-center m-4 gap-x-8">
          <nut-button type="default" @click="show = false">取 消</nut-button>
          <nut-button type="success" @click="show = false">确定添加</nut-button>
        </view>
      </view>
    </nut-popup>
  </view>
</template>

<script setup>
import { ref } from "vue";
import { IconFont } from "@nutui/icons-vue-taro";
import tags from "./tags.vue";
import tab from "./tab.vue";

const show = ref(false)
const value = ref(2)
const value2 = ref(2)
const list = ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
// import { Cell } from "plugin://materialPlugin/cell";
const url = ref("https://www.baidu.com");


const tabList1 = ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(item => ({id: item, title: `根 ${item}`})))
const tabList2 = ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(item => ({id: item, title: `父 ${item}`})))
const tabList3 = ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(item => ({id: item, title: `子 ${item}`})))
const tab1 = ref(tabList1.value[0].id)
const tab2 = ref(tabList2.value[0].id)
const tab3 = ref(tabList3.value[0].id)

const tabList = ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(item => ({id: item, title: `根 ${item}`})))
const active = ref(0)

const startmessage = (e) => {
  console.log("startmessage", e);
};


const completemessage = (e) => {
  console.log("completemessage", e);
};

const onJoin = () => {
  console.log("onJoin", window);
  // wx.invoke('joinMember', {
  //   memberId: '1234567890',
  //   success: (res) => {
  //     console.log(res)
  //   },
  //   fail: (err) => {
  //     console.log(err)
  //   }
  // })
  const JSAPI_TICKET = "sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg ";

  ww.register({
    corpId: "ww7ca4776b2a70000",
    jsApiList: ["selectExternalContact"],
    getConfigSignature() {
      console.log("getConfigSignature");
      return ww.getSignature(JSAPI_TICKET);
    },
  });

  // 调用 register 后可以立刻调用其他 JS 接口
  ww.selectExternalContact({
    success(res) {
      console.log("selectExternalContact", res);
      alert(JSON.stringify(res));
    },
  });
};
</script>
